package com.itttq.tools.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.itttq.tools.web.domain.to.HomeTo;
import com.itttq.tools.web.domain.to.LatestUserTo;
import com.itttq.tools.web.domain.to.ResultDataTo;
import com.itttq.tools.web.domain.to.ResultTo;
import com.itttq.tools.web.domain.to.StatTo;
import com.itttq.tools.web.domain.to.ThirtyRankTo;

@RestController
public class WebController {
	@RequestMapping("/home.data")
	@ResponseBody
	public ResultDataTo<HomeTo> getHomeDate() {
		ResultDataTo<HomeTo> rt = new ResultDataTo<HomeTo>(ResultTo.SUCCESS);
		HomeTo homeTo= new HomeTo();
		StatTo statTo = new StatTo();
		statTo.setSevenMoney(361.76);
		statTo.setSevenNum(45);
		statTo.setTodayNum(5);
		statTo.setTodayMoney(128.43);
		statTo.setThirtyMoney(1910.81);
		statTo.setThirtyNum(261);
		statTo.setAllMoney(7910.81);
		statTo.setAllNum(961);
		homeTo.setStat(statTo);
		List<ThirtyRankTo> ranks = new ArrayList<ThirtyRankTo>();
		for(int i =0; i< 10; i++) {
			ThirtyRankTo rank = new ThirtyRankTo();
			rank.setImg("http://www.xiongmao1718.com/api/thumb/e82aa4d5eceba8bc577a0c020afa8a44.jpg");
			rank.setNumber(i);
			rank.setTitle("八方品麻辣火锅底料300g30袋/件麻辣" + i);
			ranks.add(rank);
		}
		homeTo.setThirtyRank(ranks);
		List<LatestUserTo> latestUser = new ArrayList<LatestUserTo>();
		for(int i =0; i< 10; i++) {
			LatestUserTo user = new LatestUserTo();
			user.setAvatar("http://static.xiongmao1718.com/style/images/head-001.jpg");
			user.setUsername("张三");
			latestUser.add(user);
		}
		homeTo.setLatestUser(latestUser);
		rt.setData(homeTo);
		return rt;
	}
	

	@RequestMapping("/key.data")
	@ResponseBody
	public ResultDataTo<Map<Integer, String>> getKeyDate(int t) {
		ResultDataTo<Map<Integer, String>> rt = new ResultDataTo<Map<Integer, String>>(ResultTo.SUCCESS);
		Map<Integer, String> keyMap= new HashMap<Integer, String>();
		if(t == 1) {
			keyMap.put(1, "未上架");
			keyMap.put(2, "已上架");
			keyMap.put(3, "已删除");
		} else {
			keyMap.put(1, "热卖");
			keyMap.put(2, "新品");
			keyMap.put(3, "让利");
		}
		return rt;
	}
}
